public class String_2 {
    public static void main1(String[] args) {
        char[] ch = new char[]{'a', 'b', 'c'};
        String s1 = new String(ch); // s1对象并不在常量池中
        //s1.intern(); //s1.intern()；调用之后，会将s1对象的引用放入到常量池中
        String s2 = "abc"; // "abc" 在常量池中存在了，s2创建时直接用常量池中"abc"的引用
        System.out.println(s1 == s2);
    }

    public static void main2(String[] args) {
        StringBuilder s1 = new StringBuilder("hello");
        System.out.println(s1);
        StringBuilder s2 = s1.reverse();
        System.out.println(s2);

    }

    public static void main3(String[] args) {
        //1、String=》StringBuilder
        StringBuilder s1 = new StringBuilder("hello");
        s1.append(" world");

        //2、StringBuilder=>String
        String s2 = s1.toString();
        System.out.println(s1);
    }

    public static void main(String[] args) {
        StringBuilder sb1 = new StringBuilder("hello");
        StringBuilder sb2 = sb1;

        sb1.append(" world"); // hello world
        System.out.println(sb1==sb2);
    }
}
